Last updated: 2022-03-29
Checks: 6 1
Knit directory: S:/KJP_Biolabor/Projects/scSeq_Hefendehl/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20220131) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 87439a3. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rproj.user/
Ignored: analysis/figure/
Ignored: data/ReloadAllData_Hefendehl_Stroke_Dec'21.RData
Ignored: data/Sample_Tables/
Ignored: data/counts.csv
Ignored: data/genecounts.csv
Ignored: data/microglia_protein.rds
Ignored: data/samples.integrated.RData
Ignored: data/tx2genes.csv
Ignored: output/Descriptives.Rmd
Ignored: output/Descriptives.docx
Untracked files:
Untracked: geneviewer/
Untracked: workflow_helper.R
Unstaged changes:
Modified: analysis/01_Biostat.Rmd
Modified: code/custom_functions.R
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.
#get sample data
samples.integrated@meta.data %>% as.data.frame() -> samplemeta
# convert to correct data type
# define genotype as is
samplemeta$Genotype_corr = factor(samplemeta$Genotype=="wt", levels=c(F,T), labels = c("APPPS1+", "WT"))
samplemeta$Genotype_corr = relevel(samplemeta$Genotype_corr, ref="WT")
samplemeta$methoxy = factor(samplemeta$Genotype=="MX04+", levels=c(T,F), labels = c("MX04+", "MX04-"))
samplemeta$Treatment = as.factor(samplemeta$Treatment)
samplemeta$Treatment = relevel(samplemeta$Treatment, ref="Ctrl")
samplemeta$Mouse_ID = as.factor(samplemeta$Mouse_ID)
samplemeta$Sex = as.factor(samplemeta$Sex)
samplemeta$Brain_region = as.factor(samplemeta$Brain_region)
samplemeta$Celltype = as.factor(samplemeta$Celltype)
nCells=nrow(samplemeta)
nMice=nlevels(samplemeta$Mouse_ID)
nCelltypes=nlevels(samplemeta$Celltype)
Data contains a total of 649 Cells from 9. Q: Original raw datset containing only frankfurt data included 1149 cells. What were the filter criteria in the primary cell type analysis
Cells per Mouse
Cells per Strain
table(Mouse_ID=samplemeta$Mouse_ID) %>% as.data.frame() %>% display_tab()
Cells per Genotype
table(Genotype=samplemeta$Genotype_corr, Treatment=samplemeta$Treatment) %>% as.data.frame() %>% display_tab()
table(Genotype=samplemeta$Genotype_corr, Celltype=samplemeta$Celltype) %>%
as.data.frame() %>% display_tab()
table(Genotype=samplemeta$Genotype_corr,
Celltype=samplemeta$Celltype, Treatment=samplemeta$Treatment
) %>%
as.data.frame() %>% display_tab()
variables=c("Celltype","Sex", "Genotype_corr", "Treatment","Phase", "Brain_region","nCount_RNA","pseudoaligned_reads", "percent.mito", "percent.ribo", "Mouse_ID")
Descriptive stats across Cell type
res = compareGroups(Celltype~., data = samplemeta[,variables], max.ylev = 10)
#summary(res)
export_table <- createTable(res)
options(width = 10000)
export2md(export_table)
| T/NK | Microglia_0 | Microglia_1 | Microglia_2 | Microglia_3 | Microglia_4 | Microglia_5 | Granulocytes | p.overall | |
|---|---|---|---|---|---|---|---|---|---|
| N=22 | N=186 | N=164 | N=107 | N=99 | N=26 | N=23 | N=22 | ||
| Sex: | . | ||||||||
| f | 6 (27.3%) | 27 (14.5%) | 21 (12.8%) | 11 (10.3%) | 11 (11.1%) | 1 (3.85%) | 2 (8.70%) | 8 (36.4%) | |
| m | 16 (72.7%) | 159 (85.5%) | 143 (87.2%) | 96 (89.7%) | 88 (88.9%) | 25 (96.2%) | 21 (91.3%) | 14 (63.6%) | |
| Genotype_corr: | <0.001 | ||||||||
| WT | 3 (13.6%) | 66 (35.5%) | 93 (56.7%) | 51 (47.7%) | 44 (44.4%) | 15 (57.7%) | 11 (47.8%) | 6 (27.3%) | |
| APPPS1+ | 19 (86.4%) | 120 (64.5%) | 71 (43.3%) | 56 (52.3%) | 55 (55.6%) | 11 (42.3%) | 12 (52.2%) | 16 (72.7%) | |
| Treatment: | <0.001 | ||||||||
| Ctrl | 3 (13.6%) | 101 (54.3%) | 113 (68.9%) | 70 (65.4%) | 68 (68.7%) | 21 (80.8%) | 12 (52.2%) | 2 (9.09%) | |
| Stroke | 19 (86.4%) | 85 (45.7%) | 51 (31.1%) | 37 (34.6%) | 31 (31.3%) | 5 (19.2%) | 11 (47.8%) | 20 (90.9%) | |
| Phase: | 0.002 | ||||||||
| G1 | 1 (4.55%) | 79 (42.5%) | 70 (42.7%) | 59 (55.1%) | 42 (42.4%) | 12 (46.2%) | 14 (60.9%) | 5 (22.7%) | |
| G2M | 11 (50.0%) | 50 (26.9%) | 38 (23.2%) | 17 (15.9%) | 21 (21.2%) | 6 (23.1%) | 4 (17.4%) | 11 (50.0%) | |
| S | 10 (45.5%) | 57 (30.6%) | 56 (34.1%) | 31 (29.0%) | 36 (36.4%) | 8 (30.8%) | 5 (21.7%) | 6 (27.3%) | |
| Brain_region: | <0.001 | ||||||||
| Cortex | 3 (13.6%) | 101 (54.3%) | 113 (68.9%) | 70 (65.4%) | 68 (68.7%) | 21 (80.8%) | 12 (52.2%) | 2 (9.09%) | |
| Lesion | 19 (86.4%) | 85 (45.7%) | 51 (31.1%) | 37 (34.6%) | 31 (31.3%) | 5 (19.2%) | 11 (47.8%) | 20 (90.9%) | |
| nCount_RNA | 164049 (80916) | 150451 (78955) | 134224 (54802) | 170420 (76702) | 152640 (72678) | 172200 (70772) | 176087 (64299) | 144828 (65899) | 0.002 |
| pseudoaligned_reads | 165078 (81748) | 150942 (78850) | 134355 (54810) | 170750 (76639) | 152790 (72668) | 172433 (70717) | 176390 (64225) | 145316 (65972) | 0.002 |
| percent.mito | 2.23 (0.90) | 1.75 (1.17) | 1.62 (1.01) | 2.07 (1.07) | 1.72 (1.15) | 1.97 (1.02) | 2.11 (0.77) | 0.92 (1.00) | <0.001 |
| percent.ribo | 6.53 (2.72) | 2.68 (1.58) | 2.75 (1.81) | 2.44 (1.24) | 3.28 (1.67) | 2.11 (0.85) | 2.91 (1.35) | 2.01 (1.17) | <0.001 |
| Mouse_ID: | . | ||||||||
| 23#15773 | 0 (0.00%) | 7 (3.76%) | 25 (15.2%) | 12 (11.2%) | 17 (17.2%) | 4 (15.4%) | 1 (4.35%) | 0 (0.00%) | |
| 23#15774 | 0 (0.00%) | 1 (0.54%) | 30 (18.3%) | 10 (9.35%) | 6 (6.06%) | 1 (3.85%) | 1 (4.35%) | 0 (0.00%) | |
| 23#15792 | 1 (4.55%) | 11 (5.91%) | 13 (7.93%) | 9 (8.41%) | 6 (6.06%) | 6 (23.1%) | 1 (4.35%) | 0 (0.00%) | |
| 386 | 1 (4.55%) | 14 (7.53%) | 9 (5.49%) | 2 (1.87%) | 6 (6.06%) | 1 (3.85%) | 5 (21.7%) | 3 (13.6%) | |
| 387 | 11 (50.0%) | 10 (5.38%) | 5 (3.05%) | 6 (5.61%) | 5 (5.05%) | 0 (0.00%) | 1 (4.35%) | 6 (27.3%) | |
| 388 | 1 (4.55%) | 41 (22.0%) | 21 (12.8%) | 18 (16.8%) | 21 (21.2%) | 5 (19.2%) | 6 (26.1%) | 0 (0.00%) | |
| 409 | 1 (4.55%) | 33 (17.7%) | 16 (9.76%) | 18 (16.8%) | 9 (9.09%) | 3 (11.5%) | 3 (13.0%) | 3 (13.6%) | |
| 457 | 1 (4.55%) | 41 (22.0%) | 24 (14.6%) | 21 (19.6%) | 18 (18.2%) | 5 (19.2%) | 3 (13.0%) | 2 (9.09%) | |
| 461 | 6 (27.3%) | 28 (15.1%) | 21 (12.8%) | 11 (10.3%) | 11 (11.1%) | 1 (3.85%) | 2 (8.70%) | 8 (36.4%) |
export2xls(export_table,paste0(home,"/docs/Descriptives.xlsx"))
download data as excel file here
#get normalized counts
# question to Desiree hat the Seurat object been initialized with normalized data?
counts <- samples.integrated@assays$RNA@counts %>% as.data.frame()
# drop no variance data and sort by samplemeta
counts <- counts[apply(counts,1, sd) > 0, rownames(samplemeta)]
# drop genes with low detection rate (more than 5 counts per cell)
counts_per_celltype=apply(counts, 1, function(x){tapply(x, samplemeta$Celltype, function(z){sum(z>5,na.rm=T)})})
# keep RNAs with at least 10 cells with goood expression
idx=which(colSums(counts_per_celltype)>10)
counts = counts[idx,]
counts %>% display_tab()
Warning in instance$preRenderHook(instance): It seems your data is too big for client-side DataTables. You may consider server-side processing: https://rstudio.github.io/DT/server.html